package com.wqc.service;

import com.wqc.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    RedisTemplate<String,String> redisTemplate;

    @Override
    public void put(User user) {
        redisTemplate.opsForHash().put(user.getObjectKey(), user.getName(), user);
    }

    @Override
    public void delete(User key) {
        redisTemplate.opsForHash().delete(key.getObjectKey(), key.getName());
    }

    @Override
    public User get(User key) {
        return (User) redisTemplate.opsForHash().get(key.getObjectKey(), key.getName());
    }
}
